package com.cloudsigns.factorymanager2.project.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.bean.SurveyFeedBackForBaseInfoBean;
import com.cloudsigns.factorymanager2.project.myinerface.ItemClickListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tony on 2018/8/10.
 */

public class SurveyFeedBackForBaseInfoAdapter extends BaseAdapter {
    private Context context;
    private List<SurveyFeedBackForBaseInfoBean> datas = new ArrayList<SurveyFeedBackForBaseInfoBean>();
    private LayoutInflater inflater;
    private ItemClickListener itemClickListener;
    private String tag = "";


    public SurveyFeedBackForBaseInfoAdapter(Activity context, String tag) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
        this.tag = tag;

    }

    //    EngineeringDailyFeedBackBean
    public void setData(List<SurveyFeedBackForBaseInfoBean> list) {

        if (null != list) {
            this.datas.clear();
            this.datas.addAll(list);
        }

    }

    public void setItemClick(ItemClickListener clickListener) {
        this.itemClickListener = clickListener;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public SurveyFeedBackForBaseInfoBean getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup viewGroup) {
        final ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = inflater.inflate(R.layout.item_survey_feedback_for_baseinfo, null);
            holder.tv_content = convertView.findViewById(R.id.tv_content);
            holder.tv_value = convertView.findViewById(R.id.tv_value);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        SurveyFeedBackForBaseInfoBean surveyFeedBackForBaseInfoBean = datas.get(position);
        if (null != surveyFeedBackForBaseInfoBean) {
            holder.tv_content.setText(surveyFeedBackForBaseInfoBean.getCategoryDesc());
            holder.tv_value.setText(surveyFeedBackForBaseInfoBean.getDesc());
        }

        return convertView;
    }

    private class ViewHolder {
        private TextView tv_content;
        private TextView tv_value;


    }
}
